﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.Mvc;
using System.Web.Routing;

namespace Romantics.WebUI
{
    public class RouteConfig
    {
        public static void RegisterRoutes(RouteCollection routes)
        {
            routes.IgnoreRoute("{resource}.axd/{*pathInfo}");

            #region Hike

            routes.MapRoute(
                name: "HikeByCategory",
                url: "category/{category_url}/{page}",
                defaults: new { controller = "Hike", action = "category", category_url = "", page = 1 },
                constraints: new { page = @"\d+" }
            );

            routes.MapRoute(
                name: "HikeByCategoryFirstPage",
                url: "category/{category_url}",
                defaults: new { controller = "Hike", action = "category", category_url = "", page = 1 },
                constraints: new { page = @"\d+" }
            );

            routes.MapRoute(
                name: "HikeByRegion",
                url: "Region/{region_url}/{page}",
                defaults: new { controller = "Hike", action = "Region", region_url = "", page = 1 },
                constraints: new { page = @"\d+" }
            );

            routes.MapRoute(
                name: "HikeByRegionFirstPage",
                url: "Region/{region_url}",
                defaults: new { controller = "Hike", action = "Region", region_url = "", page = 1 },
                constraints: new { page = @"\d+" }
            );

            routes.MapRoute(
                name: "HikesPage",
                url: "Hikes/{page}",
                defaults: new { controller = "Hike", action = "Index", page = 1 },
                constraints: new { page = @"\d+" }
            );

            routes.MapRoute(
                name: "HikesPageFirstPage",
                url: "Hikes",
                defaults: new { controller = "Hike", action = "Index", page = 1 }
            );

            routes.MapRoute(
                name: "HikeID",
                url: "Hike/{id}",
                defaults: new { controller = "Hike", action = "Hike", id = 1 },
                constraints: new { id = @"\d+" }
            );

            #endregion

            #region Archive

            routes.MapRoute(
                name: "ArchiveByCategory",
                url: "Archives/{year}/category/{category_url}/{page}",
                defaults: new { controller = "Archive", action = "category", category_url = "", page = 1, year = "" },
                constraints: new { page = @"\d+", year = @"\d+" }
            );

            routes.MapRoute(
                name: "ArchiveByCategoryYear",
                url: "Archives/{year}/category/{page}",
                defaults: new { controller = "Archive", action = "category", category_url = "", page = 1, year = "" },
                constraints: new { page = @"\d+", year = @"\d+" }
            );

            routes.MapRoute(
                name: "ArchiveByCategoryFirstPage",
                url: "Archives/{year}/category/{category_url}",
                defaults: new { controller = "Archive", action = "category", category_url = "", page = 1, year = "" },
                constraints: new { year = @"\d+" }
            );

            routes.MapRoute(
                name: "ArchiveByCategoryAllYears",
                url: "Archives/category/{category_url}/{page}",
                defaults: new { controller = "Archive", action = "category", category_url = "", page = 1, year = "" },
                constraints: new { page = @"\d+" }
            );

            routes.MapRoute(
                name: "ArchiveByCategoryYearFirstPage",
                url: "Archives/{year}/category",
                defaults: new { controller = "Archive", action = "category", category_url = "", page = 1, year = "" },
                constraints: new { year = @"\d+" }
            );

            routes.MapRoute(
                name: "ArchiveByCategoryAllYearsFirstPage",
                url: "Archives/category/{category_url}",
                defaults: new { controller = "Archive", action = "category", category_url = "", page = 1, year = "" }
            );

            routes.MapRoute(
                name: "ArchiveByRegion",
                url: "Archives/{year}/Region/{region_url}/{page}",
                defaults: new { controller = "Archive", action = "Region", region_url = "", page = 1, year = "" },
                constraints: new { page = @"\d+", year = @"\d+" }
            );

            routes.MapRoute(
                name: "ArchiveByRegionYear",
                url: "Archives/{year}/Region/{page}",
                defaults: new { controller = "Archive", action = "Region", region_url = "", page = 1, year = "" },
                constraints: new { page = @"\d+", year = @"\d+" }
            );

            routes.MapRoute(
                name: "ArchiveByRegionFirstPage",
                url: "Archives/{year}/Region/{region_url}",
                defaults: new { controller = "Archive", action = "Region", region_url = "", page = 1, year = "" },
                constraints: new {year = @"\d+" }
            );

            routes.MapRoute(
                name: "ArchiveByRegionAllYears",
                url: "Archives/Region/{region_url}/{page}",
                defaults: new { controller = "Archive", action = "Region", region_url = "", page = 1, year = "" },
                constraints: new { page = @"\d+" }
            );

            routes.MapRoute(
                name: "ArchiveByRegionYearFirstPage",
                url: "Archives/{year}/Region",
                defaults: new { controller = "Archive", action = "Region", region_url = "", page = 1, year = "" },
                constraints: new { year = @"\d+" }
            );

            routes.MapRoute(
                name: "ArchiveByRegionAllYearsFirstPage",
                url: "Archives/Region/{region_url}",
                defaults: new { controller = "Archive", action = "Region", year = "", region_url = "", page = 1 }
            );

            routes.MapRoute(
                name: "ArchiveYearPage",
                url: "Archives/{year}/{page}",
                defaults: new { controller = "Archive", action = "Index", region_url = "", page = 1, year = "" },
                constraints: new { year = @"\d+", page = @"\d+" }
            );

            routes.MapRoute(
                name: "ArchivePage",
                url: "Archives/All/{page}",
                defaults: new { controller = "Archive", action = "Index", page = 1, year = "" },
                constraints: new { page = @"\d+" }
            );

            routes.MapRoute(
                name: "ArchiveID",
                url: "Archive/{id}",
                defaults: new { controller = "Archive", action = "Archive", id = 1 },
                constraints: new { id = @"\d+" }
            );

            routes.MapRoute(
                name: "ArchivePageFirstPage",
                url: "Archives",
                defaults: new { controller = "Archive", action = "Index", page = 1, year = "" }
            );

            routes.MapRoute(
               name: "Report",
               url: "Report/{id}",
               defaults: new { controller = "Archive", action = "Report", id = 1 },
               constraints: new { id = @"\d+" }
            );

            #endregion

            #region PhotoAlbum

            routes.MapRoute(
                name: "PhotoAlbumByCategory",
                url: "PhotoAlbums/{year}/category/{category_url}/{page}",
                defaults: new { controller = "PhotoAlbum", action = "category", category_url = "", page = 1, year = "" },
                constraints: new { page = @"\d+", year = @"\d+" }
            );

            routes.MapRoute(
                name: "PhotoAlbumByCategoryYear",
                url: "PhotoAlbums/{year}/category/{page}",
                defaults: new { controller = "PhotoAlbum", action = "category", category_url = "", page = 1, year = "" },
                constraints: new { page = @"\d+", year = @"\d+" }
            );

            routes.MapRoute(
                name: "PhotoAlbumByCategoryFirstPage",
                url: "PhotoAlbums/{year}/category/{category_url}",
                defaults: new { controller = "PhotoAlbum", action = "category", category_url = "", page = 1, year = "" },
                constraints: new { year = @"\d+" }
            );

            routes.MapRoute(
                name: "PhotoAlbumByCategoryYearFirstPage",
                url: "PhotoAlbums/{year}/category",
                defaults: new { controller = "PhotoAlbum", action = "category", category_url = "", page = 1, year = "" },
                constraints: new { year = @"\d+" }
            );

            routes.MapRoute(
                name: "PhotoAlbumByCategoryAllYears",
                url: "PhotoAlbums/category/{category_url}/{page}",
                defaults: new { controller = "PhotoAlbum", action = "category", category_url = "", page = 1, year = "" },
                constraints: new { page = @"\d+" }
            );

            routes.MapRoute(
                name: "PhotoAlbumByCategoryAllYearsFirstPage",
                url: "PhotoAlbums/category/{category_url}",
                defaults: new { controller = "PhotoAlbum", action = "category", category_url = "", page = 1, year = "" }
            );

            routes.MapRoute(
                name: "PhotoAlbumByRegion",
                url: "PhotoAlbums/{year}/Region/{region_url}/{page}",
                defaults: new { controller = "PhotoAlbum", action = "Region", region_url = "", page = 1, year = "" },
                constraints: new { page = @"\d+", year = @"\d+" }
            );

            routes.MapRoute(
                name: "PhotoAlbumByRegionYear",
                url: "PhotoAlbums/{year}/Region/{page}",
                defaults: new { controller = "PhotoAlbum", action = "Region", region_url = "", page = 1, year = "" },
                constraints: new { page = @"\d+", year = @"\d+" }
            );

            routes.MapRoute(
                name: "PhotoAlbumByRegionFirstPage",
                url: "PhotoAlbums/{year}/Region/{region_url}",
                defaults: new { controller = "PhotoAlbum", action = "Region", region_url = "", page = 1, year = "" },
                constraints: new { year = @"\d+" }
            );

            routes.MapRoute(
                name: "PhotoAlbumByRegionYearFirstPage",
                url: "PhotoAlbums/{year}/Region",
                defaults: new { controller = "PhotoAlbum", action = "Region", region_url = "", page = 1, year = "" },
                constraints: new { year = @"\d+" }
            );

            routes.MapRoute(
                name: "PhotoAlbumByRegionAllYears",
                url: "PhotoAlbums/Region/{region_url}/{page}",
                defaults: new { controller = "PhotoAlbum", action = "Region", region_url = "", page = 1, year = "" },
                constraints: new { page = @"\d+" }
            );

            routes.MapRoute(
                name: "PhotoAlbumByRegionAllYearsFirstPage",
                url: "PhotoAlbums/Region/{region_url}",
                defaults: new { controller = "PhotoAlbum", action = "Region", year = "", region_url = "", page = 1 }
            );

            routes.MapRoute(
                name: "PhotoAlbumYearPage",
                url: "PhotoAlbums/{year}/{page}",
                defaults: new { controller = "PhotoAlbum", action = "Index", region_url = "", page = 1, year = "" },
                constraints: new { year = @"\d+", page = @"\d+" }
            );

            routes.MapRoute(
                name: "PhotoAlbumPage",
                url: "PhotoAlbums/All/{page}",
                defaults: new { controller = "PhotoAlbum", action = "Index", page = 1, year = "" },
                constraints: new { page = @"\d+" }
            );

            routes.MapRoute(
                name: "PhotoAlbumIDModePage",
                url: "PhotoAlbum/{id}/{mode}/{page}",
                defaults: new { controller = "PhotoAlbum", action = "PhotoAlbum", id = 1, mode = "medium", page = 1},
                constraints: new { id = @"\d+", page = @"\d+" }
            );

            routes.MapRoute(
                name: "PhotoAlbumIDModeFirstPage",
                url: "PhotoAlbum/{id}/{mode}",
                defaults: new { controller = "PhotoAlbum", action = "PhotoAlbum", id = 1, mode = "medium", page = 1 },
                constraints: new { id = @"\d+" }
            );

            routes.MapRoute(
                name: "PhotoAlbumPageFirstPage",
                url: "PhotoAlbums",
                defaults: new { controller = "PhotoAlbum", action = "Index", page = 1, year = "" }
            );

            #endregion

            #region Photo

            routes.MapRoute(
               name: "Photo",
               url: "Photo/{id}",
               defaults: new { controller = "Photo", action = "Index", id = 1 },
               constraints: new { id = @"\d+" }
            );

            #endregion

            #region Admin

            routes.MapRoute(
                "Login",
                "Login",
                new { controller = "Admin", action = "Login" }
            );

            routes.MapRoute(
                "Logout",
                "Logout",
                new { controller = "Admin", action = "Logout" }
            );

            routes.MapRoute(
                "Manage",
                "Manage",
                new { controller = "Admin", action = "Manage" }
            );

            routes.MapRoute(
                "AdminAction",
                "Admin/{action}",
                new { controller = "Admin", action = "Login" }
            );

            #endregion

            routes.MapRoute(
                "404",
                "404",
                new { controller = "Error", action = "NotFound" }
            );

            routes.MapRoute(
                "500",
                "500",
                new { controller = "Error", action = "Index" }
            );

            routes.MapRoute(
                name : "Default",
                url : "{controller}/{action}",
                defaults : new { controller = "Home", action = "Index"}
            );

            
        }
    }
}